package com.gitee.base.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 结果类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class JsonVo {
    private int errno = 0;
    private Object data;
    private String msg;

    public static JsonVo success() {
        return success(null);
    }

    public static JsonVo success(Object data) {
        return new JsonVo(0, data, null);
    }

    public static JsonVo fail(){
        return fail(500,"系统异常");
    }

    public static JsonVo fail(int errno) {
        return fail(errno, null);
    }

    public static JsonVo fail(int errno, String msg) {
        return new JsonVo(errno, null, msg);
    }

    public static JsonVo fail(int errno, String msg, Object data) {
        return new JsonVo(errno, data, msg);
    }

    public static JsonVo badRequestErr(String msg) {
        return new JsonVo(400, null, msg);
    }
}

